#ifndef VFS_H
#define VFS_H

#include <types.h>

struct fs_node {
    uint64 dev_id;
    uint64 file_id;
    char name[100];
    uint32 size;
    uint32 seek_cursor;
    uint32 mode;
    uint32 mtime;
    uint32 atime;
    uint32 ctime;
    struct fs_node *first_child;
    struct fs_node *next_sibling;
    struct fs_node *parent;
    int32 (*open)(struct fs_node *);
    int32 (*read)(struct fs_node *, void *, uint32);
    int32 (*write)(struct fs_node *, void *, uint32);
    int32 (*close)(struct fs_node *);
    int32 (*link)(struct fs_node *, struct fs_node *);
    int32 (*seek)(struct fs_node *, uint32, int32);
    int32 (*unlink)(struct fs_node *);
};

/* 
   Mode bits 
   [4 bits type][9bits permissions]
*/

/* 
    Permissions
    U  G  W    
    rwxrwxrwx
    000000000
*/
#define FS_PERM_USER_READ    0400
#define FS_PERM_USER_WRITE   0200
#define FS_PERM_USER_EXEC    0100
#define FS_PERM_GROUP_READ   0040
#define FS_PERM_GROUP_WRITE  0020
#define FS_PERM_GROUP_EXEC   0010
#define FS_PERM_WORLD_READ   0004
#define FS_PERM_WORLD_WRITE  0002
#define FS_PERM_WORLD_EXEC   0001

/* File type */
#define FS_TYPE_REGULAR    0
#define FS_TYPE_LINK       1
#define FS_TYPE_CHARACTER  2
#define FS_TYPE_BLOCK      3
#define FS_TYPE_DIRECTORY  4
#define FS_TYPE_FIFO       5

#endif
